<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/include.inc.jsp" %>
<!DOCTYPE html>

<html>
<head>
    <%@include file="/WEB-INF/views/layout/base.ref.jsp" %>
    <%@include file="/WEB-INF/views/layout/valid.ref.jsp" %>
</head>
<body>
<form method="post" id="form1" action="${ctx}/input/inputinfo/save">
    <input type="hidden" name="id" value="${inputInfo.id}">
    <input type="hidden" name="useId" value="${inputInfo.useId}">
    <input type="hidden" name="organizeId" value="${inputInfo.organizeId}">
    <%@include file="/WEB-INF/views/login/home/toolbar.jsp" %>
    <div class="mtcontent">

        <div class="mtheader">
            <shiro:hasPermission name="inputInfo:edit">
                <a class="mtbtn one" href="#" onclick="hrefSave_OnClick('form1')"><i
                        class="mtfa mt-dui"></i><span>保存</span></a>
            </shiro:hasPermission>
            <a class="mtbtn two" href="#"
               onclick="hrefRet_OnClick('${ctx}/input/inputinfo/list?useId=${inputInfo.useId}')"><i
                    class="mtfa mt-refresh"></i><span>返回</span></a>
        </div>

        <div class="mtbody">
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel">标题：</label>
                    <span class="block mtinput mticon-input mticon-input-right">
                    <input type="text" name="caption" class="mtinput required" value="${inputInfo.caption}"/>
                    <i class="mtfa mt-star mtred"></i>
				</span>
                </div>
            </div>
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel">用途：</label>
                    <select name="use2">
                        <option value="SA" ${inputInfo.use2 eq "SA"?"checked='checked'":""}>SA</option>
                    </select>
                </div>
            </div>
            <div class="mtrow" style="display: none;">
                <div class="mtcol">
                    <label class="mtlabel">标识：</label>
                    <input type="text" name="mark" class="mtinput" value="${inputInfo.mark}"/>
                </div>
            </div>
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel"> 类型：</label>

                    <select class="mtinput" id="typeName" name="typeName">
                        <option value="text">
                            文本
                        </option>
                        <option value="number">
                            数字
                        </option>
                        <option value="select">
                            选择
                        </option>
                        <option value="date">
                            日期
                        </option>
                        <option value="batch">
                            批号
                        </option>
                    </select>
                </div>
            </div>
            <div class="mtrow number">
                <div class="mtcol">
                    <label class="mtlabel">最小值：</label>
                    <input class="mtinput" type="text" name="minVal"
                           value="${inputInfo.minVal eq null?0:inputInfo.minVal}"/>
                </div>
            </div>
            <div class="mtrow number">
                <div class="mtcol">
                    <label class="mtlabel">最大值：</label>
                    <input class="mtinput" type="text" name="maxVal"
                           value="${inputInfo.maxVal eq null?0:inputInfo.maxVal}"/>
                </div>
            </div>
            <div class="mtrow selectControl">
                <div class="mtcol">
                    <label class="mtlabel batch" title="批号(双击选择)">批号(双击选择)</label>
                    <label class="mtlabel select" title="选项(逗号分割)">选项(逗号分割)</label>
                    <input class="mtinput" type="text" name="selectItem" sysSelectResultName="result2_99999"
                           onclick="selectControlFun()" value="${inputInfo.selectItem}"/>
                </div>
            </div>
            <div class="mtrow defaultval">
                <div class="mtcol">
                    <label class="mtlabel">默认值：</label>
                    <input class="mtinput" type="text" name="defaultVal" value="${inputInfo.defaultVal}"/>
                </div>
            </div>
            <div class="mtrow">
                <div class="mtcol">
                    <label class="mtlabel">是否必填：</label>
                    <input type="hidden" name="isRequire" value="${inputInfo.isRequire}"/>
                    <input style="margin-left: 10px;" type="checkbox"
                           id="isRequireCheck" ${inputInfo.isRequire == 1 ?"checked='checked'":""}/>
                </div>
            </div>
        </div>
    </div>
</form>
</body>
</html>
<script type="text/javascript">
    $(function () {

        //绑定下拉控件事件
        $("#typeName").on("change", function () {
            var type = $("#typeName").val();
            displayinfo(type);
        });

        //绑定复选框事件
        $("#isRequireCheck").on("change", function () {
            $("input[name='isRequire']").val($("#isRequireCheck").is(":checked") ? 1 : 0);
        });

        //绑定名称文本框事件，保存标识和名称一致
        $("input[name='caption']").on("blur", function () {
            $("input[name='mark']").val($("input[name='caption']").val());
        });

        if ('${inputInfo.typeName}') {
            $("#typeName").val("${inputInfo.typeName}");
        }

        $("#typeName").change();
    })

    //控制不同类型输入项显示内容
    function displayinfo(type) {
        $(".number,.selectControl,.select,.batch").hide();
        switch (type) {
            case "text":
                $(".defaultval").show();
                break;
            case "number":
                $(".number").show();
                $(".defaultval").show();
                break;
            case "select":
                $(".select,.selectControl").show();
                $(".defaultval").show();
                selectControlFun = empty;
                break;
            case "batch":
                $(".batch,.selectControl").show();
                $(".defaultval").hide();
                selectControlFun = getPh;
                break;
        }
    }

    //选择批号
    function getPh() {
        meeting.customsearch("selectCustomCode", {index: 99999, multiple: true});
    }

    function empty() {

    }
</script>
